package cn.itsource.ymcc.feignfaack;

import cn.itsource.ymcc.domain.Login;
import cn.itsource.ymcc.feignclient.UAAFeignClient;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignClientFallbackFactory implements FallbackFactory<UAAFeignClient> {

    @Override
    public UAAFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new UAAFeignClient() {
            @Override
            public JSONResult register(Login login) {
                // 返回兜底数据
                return JSONResult.error("保存UAA_login失败！！，稍后从事");
            }
        };
    }
}
